 public class CalendarInvitation
        {
            public string Name { set; get; }
            public string EmailAddress { set; get; }
            public string Location { set; get; }
            public DateTime StartDateTime { set; get; }
            public DateTime EndDateTime { set; get; }
            public string Subject { set; get; }
            public string Body { set; get; }
        }

        public static string SendCalendarInvitation(string eMail, CalendarInvitation calendarInvitation)
        {
            try
            {

                if (!eMail.Contains("@"))
                    return null;

                int myEmailPort = 587;
                int myEmailHostName = "smtp.office365.com";                 


                SmtpClient smtpClient = new SmtpClient(myEmailHostName, myEmailPort);

                smtpClient.EnableSsl = true;
                smtpClient.UseDefaultCredentials = false;

                smtpClient.Credentials = new NetworkCredential("myEmail@mydomain.com", "myPassword");

                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

                MailMessage mailMessage = new MailMessage();

                mailMessage.From = new MailAddress("myEmail@mydomain.com", Messages.EmailNewPasswordFromIdentity);
                mailMessage.To.Add(new MailAddress(calendarInvitation.EmailAddress, calendarInvitation.Name));
                mailMessage.Subject = calendarInvitation.Subject;
                mailMessage.Body = calendarInvitation.Body;


                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.AppendLine("BEGIN:VCALENDAR");
                stringBuilder.AppendLine("PRODID:-//" + calendarInvitation.EmailAddress);
                stringBuilder.AppendLine("VERSION:2.0");
                stringBuilder.AppendLine("METHOD:REQUEST");
                stringBuilder.AppendLine("BEGIN:VEVENT");

                stringBuilder.AppendLine(string.Format("UID:{0}", Guid.NewGuid())); // HAVING THIS LINE OF CODE CAUSES THE EXCEPTION

                stringBuilder.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", calendarInvitation.StartDateTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
                stringBuilder.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\\THHmmss")));
                stringBuilder.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", calendarInvitation.EndDateTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
                stringBuilder.AppendLine(string.Format("SEQUENCE:0"));
                stringBuilder.AppendLine(string.Format("CREATED:{0:yyyyMMddTHHmmssZ}", DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\\THHmmss")));
                stringBuilder.AppendLine(string.Format("LAST-MODIFIED:{0:yyyyMMddTHHmmssZ}", DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\\THHmmss")));

                stringBuilder.AppendLine("LOCATION:" + calendarInvitation.Location);

                stringBuilder.AppendLine(string.Format("DESCRIPTION:{0}", calendarInvitation.Body));
                stringBuilder.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", calendarInvitation.Body));
                stringBuilder.AppendLine(string.Format("SUMMARY:{0}", calendarInvitation.Subject));
                stringBuilder.AppendLine(string.Format("ORGANIZER:{0}", eMail));

                stringBuilder.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", mailMessage.To[0].DisplayName, mailMessage.To[0].Address));
                stringBuilder.AppendLine("BEGIN:VALARM");
                stringBuilder.AppendLine("TRIGGER:-PT15M");
                stringBuilder.AppendLine("ACTION:DISPLAY");
                stringBuilder.AppendLine("DESCRIPTION:REMINDER");
                stringBuilder.AppendLine("END:VALARM");
                stringBuilder.AppendLine("END:VEVENT");
                stringBuilder.AppendLine("END:VCALENDAR");

                ContentType contentType = new ContentType("TEXT/CALENDAR");
                contentType.Parameters.Add("METHOD", "REQUEST");

                AlternateView alternativeView = AlternateView.CreateAlternateViewFromString(stringBuilder.ToString(), contentType);

                mailMessage.AlternateViews.Add(alternativeView);

                smtpClient.Port = myEmailPort;
                smtpClient.EnableSsl = true;
                smtpClient.Credentials = new NetworkCredential("myEmail@mydomain.com", "myPassword"); 
                try
                {
                    smtpClient.Send(mailMessage);
                    return string.Empty;
                }
                catch (Exception e) // JUMPS TO THIS EXCEPTION, WHEN HAVING UID POPULATED IN THE CODE
                {
                    return "Fail";
                }
            }
            catch { }
            return string.Empty;